<template>
  <div class="notice">
    <div class="banner inner">
      <img :src="require('../assets/images/bg_header.png')" alt="" />
    </div>
    <div class="content inner">
      <div class="notice-box">
        <!-- <h3 class="notice-title">报名须知</h3> -->
        <div class="nav_title"><span>报名须知</span></div>
        <div class="notice-main" v-html="projectInfos.regAgreement"></div>
        <div class="notice-ft">
          <el-button
            type="primary"
            :class="{ disabled: !isChecked }"
            :disabled="!isChecked"
            @click="goLogin"
            >我已阅读并同意报名须知
            <span v-if="!isChecked">( {{ time }}s )</span>
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import localDb from "../utils/localDb.js";
// import { formatDate } from "../utils/util";
import { getSysPara, getSysZt } from "../utils/api";
export default {
  name: "Notice",
  data() {
    return {
      // isChecked: true,
      isChecked: false,
      time: 0,
      times: null,
    };
  },
  created() {
    this.getSysZt();
    this.$store.dispatch("setUser", "");
  },
  methods: {
    goLogin() {
      this.$router.push({ path: "/zmkm" });
    },
    countDown() {
      // this.projectInfos.regWait--;
      this.time--;
    },
    //获取项目标题
    async getSysName(type) {
      try {
        const data = await getSysPara(type);
        if (data.res == 0) {
          this.$store.dispatch("setWpzswTitle", data.data[0].value);
        } else {
          this.$message.error(data.msg);
        }
      } catch (error) {}
    },
    async getSysZt() {
      try {
        const data = await getSysZt();
        if (data.res == 0) {
          localDb.set("emptyEnter", data.data);
          if (data.data.isMt != "0") {
            this.$router.push({ path: "/empty" });
          }
        }
      } catch (error) {}
    },
  },
  computed: {
    projectInfos() {
      return this.$store.state.frontPage.projectInfos;
    },
  },
  mounted() {
    this.$store.dispatch("fetchGetProject", {
      sucCallback: () => {},
      falCallback: () => {},
    });
    this.getSysName("SysName");
    this.time = this.projectInfos.regWait;
    this.times = setInterval(this.countDown, 1000);
  },
  watch: {
    time: function (newVal) {
      if (newVal == 0) {
        this.isChecked = true;
        clearInterval(this.times);
      }
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.notice {
  min-height: 100vh;
  // height: 100%;
  // background-color: #edf4fa;
  overflow: hidden;
  // overflow: auto;
}
.banner {
  margin-top: 30px;
  position: relative;
  z-index: 1;
  font-size: 0;
  img {
    width: 100%;
  }
}
.content {
  padding-bottom: 30px;
  .notice-box {
    // padding: 26px 90px;
    padding-bottom: 30px;
    background: #fff;
    box-shadow: 0 0 10px #ebebeb;
    .nav_title span {
      font-size: 24px;
    }
    .notice-main {
      line-height: 28px;
      color: #222;
      font-size: 16px;
      padding: 20px 60px;
      text-align: justify;
      // .title {
      //   margin-top: 30px;
      //   font-size: 16px;
      // }
      // p {
      //   text-indent: 32px;
      // }
    }
    .notice-ft {
      text-align: center;
      // margin-top: 30px;
      a {
        display: inline-block;
        width: 260px;
        height: 36px;
        line-height: 40px;
        margin: 0 8px;
        background: #0195ff;
        font-size: 16px;
        color: #fff;
        border-radius: 4px;
        text-decoration: none;
        // &:hover {
        //   background: lighten($bsC, 15%);
        // }
        // &:active {
        //   background: darken($bsC, 10%);
        // }
        &.disabled {
          background: #ccc;
        }
      }
      .el-button {
        display: inline-block;
        width: 260px;
        height: 36px;
        line-height: 36px;
        padding: 0;
        font-size: 16px;
        background: #0195ff;
        border: #0195ff;
        &.disabled {
          background: #ccc;
        }
      }
    }
    .readcheck {
      padding: 15px 0;
      line-height: 40px;
      .el-checkbox__label {
        font-size: 16px;
      }
    }
  }
}
</style>
